/*
 * Javlov - a Java toolkit for reinforcement learning with multi-agent support.
 * 
 * Copyright (c) 2009 Matthijs Snel
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package net.javlov;

/**
 * Interface for the actor part of actor-critic methods. The actor represents the policy
 * directly, but is updatable by means of the TD error received from the critic (which
 * is typically a state-value function learner).
 * 
 * This interface is therefore a blending of the {@link Policy} and {@link QFunction}
 * interfaces. It needs to select actions based on states, like any policy, but in
 * addition needs to be able to update its tendency to select certain actions in states,
 * like Q-functions. Although it is similar to a Q-function in this respect, the actor
 * typically does not store/approximate Q-values but action selection probabilities.
 * 
 * @author Matthijs Snel
 *
 */
public interface Actor extends Policy {

	/**
	 * Adds the provided TD error, multiplied by the learning rate alpha,
	 * to the current probablity of the action that was selected last.
	 * The probabilities of selecting the other actions will be decreased
	 * such that the sum of all probabilities adds to 1.
	 * 
	 * @param TDerr the TD error that will be used to update the probability of the last
	 * selected action.
	 */
	public <T> void update(double TDerr);
	
	/**
	 * Gets the learning rate alpha.
	 * 
	 * @return the learning rate alpha.
	 */
	public double getLearnRate();
	
	/**
	 * Sets the learning rate alpha.
	 * 
	 * @param alpha the learning rate
	 */
	public void setLearnRate(double alpha);
	
	/**
	 * Called at the beginning of an experiment.
	 */
	public void init();
	
	/**
	 * Called whenever the learning scenario is reset without clearing the learned values,
	 * e.g. at the beginning of a new episode in episodic tasks.
	 */
	public void reset();
}
